Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

247
Views
Typescript Type ‘string’ is not assignable to type" error

I'm trying to split this number value, but first I'm converting it into a String, and I'm getting this error.

Type ‘string’ is not assignable to type ‘number’" error

This is my code:

export const roundWithPrecision = (
  value: number,
  decimalPrecision: number,
): number => {
  let valueString: string | number = value
  let valueSplit = valueString.toString().split('')
  return valueSplit;
};

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think the function returns a string and not a number as expected.

export const roundWithPrecision = (
  value: number,
  decimalPrecision: number,
): number => {
  let valueString: string | number = value
  let valueSplit = valueString.toString().split('')
  return valueSplit*1;
};

or

export const roundWithPrecision = (
  value: number,
  decimalPrecision: number,
): string => {
  let valueString: string | number = value
  let valueSplit = valueString.toString().split('')
  return valueSplit;
};
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!